package com.easy.controller;

import com.easy.util.CaptchaUtil;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@RestController
@RequestMapping("/captcha")
public class CaptchaController {
    //返回一张图片
    @GetMapping()
    public void captcha(HttpServletResponse response, HttpSession session) {
        //生成一张验证码的图片
        // String captcha = CaptchaUtil.createCaptcha(response);
        String captcha = CaptchaUtil.createCaptcha(100,30,5,response);
        session.setAttribute("captcha", captcha);
    }
}
